import { Dispatch } from "redux";
import axios from "../untils/axios";

export let getlist = () => {
  return async (dispatch: any) => {
    let { data } = await axios.get("/api/list");
    dispatch({
      type: "GET_LIST",
      payload: data.list,
    });
  };
};

export let check_active = (index:any) => {
  return {
    type:"CHECK_ACTIVE",
    payload:index
  }
};
export let login_my = (values:object) => {
  return async(dispatch:Dispatch)=>{
    let {data}=await axios.get("/api/login",{params:values})
    dispatch({
      type:"LOGIN_MY",
      payload:Object.assign({},values,{...data})
    })
  }
};
export let reg_my = (values:object) => {
  return async()=>{
    let {data}=await axios.get("/api/reg",{params:values})
    console.log(data);
    
  }
};


export let add_shopcar_data = (id:string) =>{
  // console.log(id);
  
  return {
      type:"ADD_SHOPCAR",
      payload:id
  }
}

export let add_num=(id:string)=>{
  return {
    type:"ADD_NUM",
    payload:id
}
}
export let sub_num=(id:string)=>{
  return {
    type:"SUB_NUM",
    payload:id
}
}